import service from "/@/utils/request";

export const usePersonOrgQueryApi = (code: string,) => {
    return service({
        url: `v0/person/org/query`,
        method: 'GET',
        params: { code: code },
    });
}
export const usePersonOrgPageApi = (formData?: object) => {
    return service({
        url: `v0/person/org/page`,
        method: 'POST',
        data: formData
    });
}
export const usePersonOrgCreateApi = (formData: object) => {
    return service({
        url: `v0/person/org/create`,
        method: 'POST',
        data: formData
    });
}

export const usePersonOrgUpdateApi = (formData: object) => {
    return service({
        url: `v0/person/org/update`,
        method: 'PUT',
        data: formData
    });
}

export const usePersonOrgDeleteApi = (param: string | string[]) => {
    let arrList: string[] = []

    if (param instanceof Array) {
        arrList = param
    } else {
        arrList.push(param)
    }

    return service({
        url: `v0/person/org/delete`,
        method: 'DELETE',
        data: { codeList: arrList }
    });
}

export const usePersonOrgTreeApi = (parentCode?: string) => {
    return service({
        url: `v0/person/org/tree`,
        method: 'GET',
        params: {
            parentCode: parentCode
        }
    });
}

export const usePersonOrgChildrenApi = (parentCode?: string) => {
    return service({
        url: `v0/person/org/children`,
        method: 'GET',
        params: {
            parentCode: parentCode
        }
    });
}

export const usePersonOrgListApi = () => {
    return service({
        url: `v0/person/org/list`,
        method: 'GET'
    });
}
export const useOrgChildrenApi = (formData: object) => {
    return service({
        url: `v0/person/org/children`,
        method: 'GET',
        params: formData
    });
}